$(document).ready(function() {
    // initChart();
    var options = {
        language: config.clientLang,
        weekStart: 1,
        todayBtn: 1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        showMeridian: 1,
        minView: 2,
        format: 'yyyy-mm-dd',
        endDate: new Date(),
    };
    $('.datepicker-date input#begin,.datepicker-date input#end').fixedDate().datetimepicker(options);
    $('[data-toggle="tooltip"]').tooltip();
});
function changeParams(obj) {
    var begin = $('#conditions').find('#begin').val();
    var end = $('#conditions').find('#end').val();
    var project = $('#conditions').find('#project').val();
    var dept = $('#conditions').find('#dept').val();

    if (begin.indexOf('-') != -1) {
        var beginarray = begin.split("-");
        var begin = '';
        for (i = 0; i < beginarray.length; i++) begin = begin + beginarray[i];
    }
    if (end.indexOf('-') != -1) {
        var endarray = end.split("-");
        var end = '';
        for (i = 0; i < endarray.length; i++) end = end + endarray[i];
    }

    var link = createLink('report', 'projectSummary', 'begin=' + begin + '&end=' + end + '&dept=' + dept + '&project=' + project);
    location.href = link;
}


function changeDate(begin, end) {
    var project = $('#conditions').find('#project').val();
    var dept = $('#conditions').find('#dept').val();

    if (begin.indexOf('-') != -1) {
        var beginarray = begin.split("-");
        var begin = '';
        for (i = 0; i < beginarray.length; i++) {
            begin = begin + beginarray[i];
        }
    }
    if (end.indexOf('-') != -1) {
        var endarray = end.split("-");
        var end = '';
        for (i = 0; i < endarray.length; i++) {
            end = end + endarray[i];
        }
    }
    link = createLink('report', 'projectsummary', 'begin=' + begin + '&end=' + end + '&dept=' + dept + '&project=' + project);
    location.href = link;
}

$('#submit').on('click',function () {

    var begin = $('#conditions').find('#begin').val();
    var end = $('#conditions').find('#end').val();
    var project = $('#conditions').find('#project').val();
    var dept = $('#conditions').find('#dept').val();
    if (begin.indexOf('-') != -1) {
        var beginarray = begin.split("-");
        var begin = '';
        for (i = 0; i < beginarray.length; i++) {
            begin = begin + beginarray[i];
        }
    }
    if (end.indexOf('-') != -1) {
        var endarray = end.split("-");
        var end = '';
        for (i = 0; i < endarray.length; i++) {
            end = end + endarray[i];
        }
    }
    link = createLink('report', 'exportProjectSummary', 'begin=' + begin + '&end=' + end + '&dept=' + dept + '&project=' + project);
    location.href = link;
})
